package mypackage;

import java.util.Scanner;

public class testclass5 {
    public static void main(String[] args) {
        //评委打分
        //1获取分数
        int[] score=getarr();
        //2获取最高分
        int max=getarrmax(score);
        //3获取最低分
        int min=getarrmin(score);
        //4获取总分
        int sum=getarrsum(score);
        //5获取平均数
        double avg=getavg(sum,max,min,score.length);
        System.out.println("原数组为:");
        for (int i = 0; i < score.length; i++) {
            System.out.print(score[i]+" ");
        }
        System.out.println();
        System.out.println("最高分为:"+max);
        System.out.println("最低分为:"+min);
        System.out.println("平均分为:"+avg);
    }
    public static int[] getarr(){
        System.out.println("请输入6个0-100的整数");
        Scanner sc=new Scanner(System.in);
        int[] scores=new int[6];
        for (int i = 0; i < 6;) {
            System.out.println("请输入0-100的整数");
            int score=sc.nextInt();
            if(score>=0&&score<=100){
                scores[i]=score;
                ++i;
            }else{
                System.out.println("输入了非法数据,请重新输入,当前i为:"+i);
            }
        }
        return scores;
    }
    public static int getarrmax(int[] arr){
        int max=arr[0];
        for (int i = 1; i < arr.length; i++) {
            if(max<arr[i]){
                max=arr[i];
            }
        }
        return max;
    }
    public static int getarrmin(int[] arr){
        int min=arr[0];
        for (int i = 1; i < arr.length; i++) {
            if(min>arr[i]){
                min=arr[i];
            }
        }
        return min;
    }
    public static int getarrsum(int[] arr){
        int sum=0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }
        return sum;
    }
    public static double getavg(int sum,int max,int min,int len){
        double ans=(sum-max-min)/(len-2);
        return ans;
    }
}
